<?php

namespace App\Http\Controllers\Admin;

use App\Http\Models\Menu;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Redis;

class IndexController extends Controller
{
    public function index(){
        $menuObj = Menu::select("id","pid","name","icon","action")->orderBy("sort")->get()->toArray();
        $menu = createArrTree($menuObj);
        return view("admin.index.index",compact('menu'));
    }

    //编辑器图片上传接口
    public function imgupload(Request $request){
        $info = [
            'code' => 200,
            'url'  => ''
        ];
        if($request->file("file")){
            $info['url'] = "/uploads/".$request->file("file")->store("news/editor");
        }else{
            $info['code'] = 400;
        }
        return $info;
    }
}
